#ifndef POLICY_H
#define POLICY_H

#include <QObject>
#include <QMessageBox>


//policy flag macros

class Policy : public QObject
{
	Q_OBJECT

public:
	Policy();
	~Policy();
	
	int flags;//combination of flag macros - see above
	int minquizsuccess;//minimum percent of the quiz deemed to be successful
	int minquizforsrs;//min quiz to test srs
	int minquizformod;//min quiz to get mod
	int maxquizredo;//max quiz to be able to redo it


	////Functions about what student could do
	bool couldDoQuiz(int studentid, int lessontypeid, int lessonid);
	bool couldDoSrs(int studentid, int lessontypeid, int lessonid);
	bool couldDoMod(int studentid, int lessontypeid, int lessonid);

	////Functions about whether some type of job is complete
	bool quizComplete(int studentid, int lessontypeid);
	bool srsComplete(int studentid, int lessontypeid);
	bool modComplete(int studentid, int lessontypeid);

	//Check if variant is free and could be assigned to the student
	bool couldGetVariant(int lessontypeid, int studentid, int variantnum);

	//Finishes all attempts made open for previous lessons
	void finishPrevLessons();

	//Count srs attempts
	int countSrsTestingAttempts(int variantid, int studentid);

	//Count mod attempts
	int countModAttempts(int variantid, int studentid);

	//Count mod testing attempts: 
	//there is a question should we count attempts only for the last mod or for all mods in the lessontype
	int countModTestingAttempts(int variantid, int studentid, int modattemptid);


	////Helper functions
	//Get quiz grade for this lesson
	int quizGradeToday(int studentid, int lessontypeid, int lessonid);
	//Get last variant for srs for given student and lessontype
	int variant(int studentid, int lessontypeid);

	/////////////////Policy for unlesson grades
	static bool couldSaveGrade(int grade, QString comments);

private:
	
	
};

#endif // POLICY_H
